
/*
 * 应用Mq队列管理页面
 */
Ext.define('MyApp.view.appMQInfoManager', {
    extend: 'Ext.panel.Panel',
    id: 'appMQInfoManager',
    closable: true,
    title: '应用队列信息管理',
	queryForm: null,
	getQueryForm: function(){
		var me = this;
		if(me.queryForm==null){
			me.queryForm = Ext.widget('form',{
                layout: 'column',
				defaults: {
					margin: '10 10 10 10',
					columnWidth: .2,
					labelWidth: 80,
					xtype: 'textfield'
				},
                items: [{
					fieldLabel: '应用id',
				    columnWidth: .25,
					labelWidth: 80,
				    name: 'appId'
				},{
				    fieldLabel: '队列名称',
				    columnWidth: .25,
					labelWidth: 80,
				    name: 'queueName'
				},{
			        fieldLabel: '创建日期',
			        columnWidth: .5,
					labelWidth: 80,
			        xtype: 'rangedatefield',
			        //起始日期组件的name属性。
			        fromName: 'createStartTime',
			        //终止日期组件的name属性。
			        toName: 'createEndTime'
				}],
                buttons: [{
					text:'查询',
					handler: function() {
						me.getPagingToolbar().moveFirst();
					}
				},'-',{
					text:'重置',
					handler: function() {
						me.getQueryForm().getForm().reset();
					}
				},'->']
            });
		}
		return this.queryForm;
	},
	form: null,
	getMqForm: function(){
		var me = this;
		if(me.form==null){
			me.form = Ext.create('MyApp.view.appMQForm',{
				store: me.getStore(),
				dockedItems: [me.getPagingToolbar()]
			});
		}
		return this.form;
	},
	pagingToolbar: null,
	getPagingToolbar: function(){
		var me = this;
		if(me.pagingToolbar==null){
			me.pagingToolbar = Ext.widget('pagingtoolbar',{
				store: me.getStore(),
				dock: 'bottom',
				displayInfo: true
			});
		}
		return me.pagingToolbar;
	},
	store: null,
	getStore: function(){
		var me = this;
		if(me.store==null){
			me.store = Ext.create('MyApp.store.AppMqStore',{
				autoLoad: true,
				listeners: {
					beforeload : function(store, operation, eOpts) {
						var queryForm = me.getQueryForm();
						if (queryForm != null) {
							var values = queryForm.getValues();
							Ext.apply(operation, {
								params: {
									'createStartTime': values.createStartTime,
									'createEndTime': values.createEndTime,
									'appId': Ext.String.trim(values.appId),
									'queueName': Ext.String.trim(values.queueName)
								}
							});	
						}
					}
				}
			});
		}
		return me.store;
	},
    initComponent: function() {
        var me = this;
        Ext.applyIf(me, {
            items: [me.getQueryForm(),me.getMqForm()]
        });
        me.callParent(arguments);
    }
});
